<html>
<head>
<title>Maple</title>
</head>
<body>
<?php
    $descriptorspec = array(
    	   0 => array("pipe", "r"),  // stdin is a pipe that the child will read from
    	   1 => array("pipe", "w"),  // stdout is a pipe that the child will write to
    	   2 => array("file", "/home/projetos/anaweb/maple/error-output.txt", "a") // stderr is a file to write to
    	 );

    $cwd = '/home/projetos/anaweb/maple';
    $env = array('LD_ASSUME_KERNEL' => '2.2.15');
    $process = proc_open('/usr/local/maple/bin/maple', $descriptorspec, $pipes, $cwd, $env);
    if (is_resource($process)) {
	fwrite($pipes[0],"(2+5*I)+(1-I);\n");
        fclose($pipes[0]);
        echo "<pre>\n";	
        echo stream_get_contents($pipes[1]);
        echo "\n</pre>\n";
        fclose($pipes[1]);
    	proc_close($process);
    }
?>
</body>
</html>
